<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use common\models\shop\ShopOrder;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\shop\models\ShopOrderSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '商品订单管理';
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">
 


<div class="shop-order-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


        <?= GridView::widget([
            'dataProvider'=>$dataProvider,
            'filterModel'=>$searchModel,
            'showPageSummary'=>true,
            'pjax'=>true,
            'striped'=>true,
            'hover'=>true,
            'panel'=>['type'=>'primary', 'heading'=>' 订单管理'],
            'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
            'headerRowOptions'=>['class'=>'kartik-sheet-style'],
            'filterRowOptions'=>['class'=>'kartik-sheet-style'],
            'columns'=>[
                [
                    'attribute'=>'ordersn',
                    'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                    'width'=>'100px',
                ],
                [
                    'class'=>'kartik\grid\ExpandRowColumn',
                    'width'=>'50px',
                    'value'=>function ($model, $key, $index, $column) {
                        return GridView::ROW_COLLAPSED;
                    },
                    'detail'=>function ($model, $key, $index, $column) {
                        return Yii::$app->controller->renderPartial('detail', ['model'=>$model]);
                    },
                    'headerOptions'=>['class'=>'kartik-sheet-style'],
                    'expandOneOnly'=>true
                ],
                [
                    'label' => '下单人',
                    'value' => 'user.nickname',
                    'attribute'=>'userid',
                    'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                    'width'=>'100px',
                ],
                [
                    'attribute'=>'price',
                    'width'=>'50px',
                    'hAlign'=>'right',
                    'format'=>['decimal', 2],
                    'pageSummary'=>true
                ],
                [
                    'attribute'=>'goodsprice',
                    'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                    'width'=>'50px',
                    'format'=>['decimal', 2],
                    'pageSummary'=>true
                ],
                [
                    'attribute'=>'dispatchprice',
                    'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                    'width'=>'50px',
                    'format'=>['decimal', 2],
                    'pageSummary'=>true
                ],

                [
                    'filterType'=>GridView::FILTER_SELECT2,
                    'attribute'=>'expresscom',
                    'width'=>'150px',
                    'hAlign'=>'right',
                ],
                [
                    'attribute'=>'address',
                    'width'=>'230px',
                    'hAlign'=>'right',
                ],
                [
                    'filterType'=>GridView::FILTER_SELECT2,
                    'attribute'=>'sendtype',
                    'width'=>'150px',
                    'hAlign'=>'right',
                    'filterType'=>GridView::FILTER_SELECT2,
                    'filter'=>ShopOrder::$sendtype,
                    'filterWidgetOptions'=>[
                        'pluginOptions'=>['allowClear'=>true],
                    ],
                    'value' => function($model){
                        return $model->sendtype?ShopOrder::$sendtype[$model->sendtype]:'';
                    },
                    'filterInputOptions'=>['placeholder'=>'配送方式'],
                ],
                [
                    'filterType'=>GridView::FILTER_DATETIME,
                    'attribute'=>'createtime',
                    'value' => function($model){
                        return  date('Y-m-d H:i:s',$model->createtime);
                    },
                    'width'=>'100px',
                    'hAlign'=>'right',
                ],
                [
                    'attribute'=>'status',
                    'width'=>'100px',
                    'format' => 'raw',
                    'value'=>function ($model, $key, $index, $widget) {
                        if($model->status==ShopOrder::STATUS_MANAL) {
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-default']);
                        }else if($model->status==ShopOrder::STATUS_PAY){
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-primary']);
                        }else if($model->status==ShopOrder::STATUS_RECEIVE){
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-info']);
                        }else if($model->status==ShopOrder::STATUS_FINISH){
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-success']);
                        }else if($model->status==ShopOrder::STATUS_CANCAL){
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-danger']);
                        }else if($model->status==ShopOrder::STATUS_PAYFAIL){
                            return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-warning']);
                        }

                        return Html::label(ShopOrder::$statues[$model->status], '', ['class' => 'btn btn-xs btn-default']);
                    },
                    'filterType'=>GridView::FILTER_SELECT2,
                    'filter'=> ShopOrder::$statues,
                    'filterWidgetOptions'=>[
                        'pluginOptions'=>['allowClear'=>true],
                    ],
                    'filterInputOptions'=>['placeholder'=>'选择状态']
                ],
                [
                    'class' => '\kartik\grid\ActionColumn',
                    'deleteOptions' => ['label' => '<i class="glyphicon glyphicon-remove"></i>']
                ],
            ],
            'toolbar'=> [
                Yii::$app->request->get('id') !== null?[
                    'content' => Html::button('<i class="glyphicon glyphicon-plus"></i>', ['type'=>'button', 'title'=>'选中归为档案', 'class'=>'btn btn-success', 'id'=>'addpig'])
                ]:'',
                '{export}',
                '{toggleData}',
            ],
            'bordered'=>true,
            'condensed'=>true,
        ]);
        ?>
</div>
</div>
</div>
</section>
</section>





